package cn.xxxy.fourm.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.xxxy.fourm.dao.UserStateDao;
import cn.xxxy.fourm.entity.UserState;
import cn.xxxy.fourm.model.UserStateDto;
import cn.xxxy.fourm.service.UserStateService;
@Service@Transactional
public class UserStateServiceImpl implements UserStateService{
	@Autowired
	private UserStateDao userStateDao;
	@Override
	public List<UserStateDto> listUserStates() {
		List<UserState> lists=userStateDao.findAll();
		List<UserStateDto> lists1=new ArrayList<>();
		for (UserState userState : lists) {
			UserStateDto userStateDto=new UserStateDto();
			userStateDto.setId(userState.getSid());
			userStateDto.setText(userState.getSname());
			if(userState.getSid()==1) {
				userStateDto.setSelected(true);
			}else {
				userStateDto.setSelected(false);
			}
			lists1.add(userStateDto);
		}
		return lists1;
	}

}
